<template>
	<view class="notice_list">
		<uv-navbar leftIcon="arrow-leftward" leftIconColor="#FFF" placeholder autoBack bgColor="#161714">
			<!-- <template v-slot:left>
				<view class="left_slot">
					<image src="@/static/images/logo.png"></image>
				</view>
			</template> -->
			<template v-slot:center>
				<view class="center_slot">公告中心</view>
			</template>
		</uv-navbar>
		<view class="list">
			<view class="item" v-for="item in _this.list" @click="router(`/pages/home/notice_deta?id=${item.id}`)">
				<view class="item_view">
					<image :src="item.img" class="cover"></image>
					<view class="item_info">
						<view class="type">{{item.title}}</view>
						<view class="time">{{item.created_at}}</view>
					</view>
					<uv-icon name="arrow-right" color="#fff" size="15"></uv-icon>
				</view>
				<view class="synopsis">{{item.synopsis}}</view>
			</view>
			<uv-load-more :status="_this.loadmore_status" line @loadmore="loadmore" />
		</view>
	</view>
</template>

<script setup>
	import {
		newLists
	} from "@/request/api";
	import {
		onReachBottom
	} from "@dcloudio/uni-app";
	import useBase from "@/hooks/useBase.js";
	import useList from "@/hooks/useList.js";
	const {
		router
	} = useBase();
	const {
		_this
	} = useList();
	const getList = async () => {
		let {
			list
		} = await newLists({
			page: _this.page,
			limit: _this.limit,
		});
		_this.last_page = list.last_page;
		list = list.list;
		_this.list = _this.page == 1 ? list : [..._this.list, ...list];
		_this.loadmore_status = _this.last_page == _this.page ? 'nomore' : 'loadmore';
	};
	getList();
	const loadmore = () => {
		if (_this.page >= _this.last_page) return;
		_this.page++;
		getList();
	};
	onReachBottom(() => loadmore());
</script>

<style scoped lang="scss">
	.notice_list {
		.center_slot {
			color: #FFFFFF;
			font-size: 18px;
			font-weight: bold;
		}

		.list {
			padding: 0 20rpx;
			box-sizing: border-box;

			.item {
				border-radius: 20rpx;
				margin-top: 30rpx;
				padding: 40rpx 35rpx 48rpx;
				box-sizing: border-box;
				background: #2F2F2F;

				.item_view {
					display: flex;

					.cover {
						width: 88rpx;
						height: 88rpx;
						border-radius: 44rpx;
						background: #8BCBA4;
					}

					.item_info {
						flex: 1;
						padding: 4rpx 20rpx 18rpx;
						box-sizing: border-box;
						display: flex;
						flex-direction: column;
						justify-content: space-between;

						.type {
							color: #FFFFFF;
							font-size: 28rpx;
							font-weight: 800;
						}

						.time {
							color: #9198AB;
							font-size: 24rpx;
							font-family: DINPro;
						}
					}
				}

				.synopsis {
					line-height: 40rpx;
					color: #999999;
					font-size: 26rpx;
					padding-top: 42rpx;
					box-sizing: border-box;
				}
			}
		}
	}
</style>